package lupos;

import org.w3c.dom.Element;

/** 
 * The role of this class is to parse 'lexeme' elements in 
 * FrameNet 1.3 annotation files. The structure of these 
 * elements is as follows:
 * 
 *   lexeme @ID @pos @breakBefore @headword #PCDATA
 *   
 * The @ID attribute is ignored. There is also a method toXML() 
 * to write the object back into XML as part of a lexical 
 * entry. 
 */

public class Lexeme {

	public String pos;
	public String breakBefore;
	public String headWord;
	public String text;
	
	public Lexeme(Element e) {
		pos = e.getAttribute("pos");
		breakBefore = e.getAttribute("breakBefore");
		if (e.hasAttribute("headword")) headWord = e.getAttribute("headword");
		else headWord = e.getAttribute("headWord");
		text = e.getTextContent();
	}
	
	public String toXML() {
		String s = "    <word pos=\"";
		s = s + pos + "\" breakBefore=\"";
		s = s + breakBefore + "\" headWord=\"";
		s = s + headWord + "\">";
		s = s + text;
		return s + "</word>\n";
	}
	
}
